package com.xhsj.user.sms.purchase.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xhsj.user.sms.purchase.entity.TbPurchaseOrder;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 采购订单-主表 Mapper 接口
 * </p>
 *
 * @author suxiaolin
 * @since 2020-04-23
 */
@Mapper
public interface TbPurchaseOrderMapper extends BaseMapper<TbPurchaseOrder> {

    // 通过id获取采购订单
    TbPurchaseOrder getPurchaseOrderById(@Param("id") String id);


    IPage<TbPurchaseOrder> findOrderList(Page<TbPurchaseOrder> page, @Param("entity") TbPurchaseOrder entity);

    //获取最新的订单任务编号
    String getOrderNewNum(@Param("kinds") String kinds);

    List<TbPurchaseOrder> getPurchaseOrderListByTaskId(@Param("taskId") String taskId);

    void delByTaskId(@Param("taskId") String taskId);

    int updateAuditStatus(@Param("dataId") String dataId);

    IPage<Map<String, Object>> findPurchaseOrder(IPage<TbPurchaseOrder> page, @Param("userId") String userId);

    int updateCreateBy(@Param("userId") Integer userId, @Param("dataId") String dataId);

    // 查询订单下游数据
    Map<String, Object> getDownstreamData(@Param("dataId") String dataId);

    // 通过采购任务id查询采购订单列表
    List<TbPurchaseOrder> getPurchaseOrderByTaskId(@Param("taskId") String taskId);
}
